import torch
image_size=28
batch_size=64
# 工具人
def weight_init(m):
    class_name = m.__class__.__name__
    if class_name.find('conv') != -1:
        m.weight.data.normal_(0, 0.02)
    if class_name.find('norm') != -1:
        m.weight.data.normal_(1.0, 0.02)


def make_show(img):
    img = img.data.expand(batch_size, 1, image_size, image_size)
    return img


def rightness(prediction, label):
    pred = torch.max(prediction.data, 1)[1]
    rights = pred.eq(label.data.view_as(pred)).sum()
    return rights, len(label)